package com.intermancer.predictor.audit;

import java.util.logging.Logger;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import com.intermancer.predictor.system.Demiurge;

public class LoggingInterceptor implements MethodInterceptor {

	private static Logger logger = Logger.getLogger(LoggingInterceptor.class.getName());
	
	@Override
	public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object[] arguments = methodInvocation.getArguments();
        System.out.println("Method invoked= " +
                methodInvocation.getMethod().getName());
//        logger.fine("Method invoked= " +
//                methodInvocation.getMethod().getName());

        for (int index = 0; index < arguments.length; index++) {
        	System.out.println("arg" + index + "= " + arguments[index]);
        	//logger.fine("arg" + index + "= " + arguments[index]);
        }
        Object returnValue = methodInvocation.proceed();
        System.out.println("returned " + returnValue);
        //logger.fine("returned " + returnValue);
        return returnValue;
	}

}
